import { ApiProperty } from '@nestjs/swagger';
import { Column, Entity, OneToMany, JoinColumn } from 'typeorm';
import { BaseEntity } from '../../../base.entity';
import BaseMachineMaintainProjectList from './base-machine-maintain-project-list.entity';

@Entity({ name: 'base_machine_maintain_project' })
export default class BaseMachineMaintainProject extends BaseEntity {
  @Column({
    type: 'varchar',
    length: 50,
    name: 'machine_code',
    unique: true,
    comment: '设备编号',
  })
  @ApiProperty()
  machineCode: string;

  @Column({ type: 'varchar', length: 50, name: 'machine_name', comment: '设备名称' })
  @ApiProperty()
  machineName: string;

  @Column({
    type: 'varchar',
    length: 50,
    name: 'machine_model',
    comment: '设备型号',
    nullable: true,
  })
  @ApiProperty()
  machineModel: string;

  @Column({ type: 'varchar', nullable: true, comment: '备注' })
  @ApiProperty()
  remark: string;

  @OneToMany(() => BaseMachineMaintainProjectList, (item) => item.machineMaintainProject)
  @JoinColumn({ name: 'machine_code', referencedColumnName: 'machineCode' })
  machineMaintainProjectList: BaseMachineMaintainProjectList[];
}
